#if !defined (MeshH)
#define MeshH

#include <d3dx9.h>		// Direct 3D library (for all Direct 3D funtions).
#include <cassert>
#include "XAnimator\XAnimator_lib.h"

class Mesh
{
public:
		Mesh();								// Default Constructor.
		~Mesh();							// Destructor.
		
		// Load mesh data from an .x file on specified D3D device (Precondition: device_ != 0)
		HRESULT LoadMesh( LPDIRECT3DDEVICE9 device, LPCTSTR filename);
		HRESULT LoadMeshXA(IXAnimator *XAnim, LPDIRECT3DDEVICE9 device, LPCTSTR filename);
		// Render the whole mesh (Precondition: device_ != 0)
		void Render() const;	
		void Render(float x, float y, float z, float rotY = 0,float scaleX = 1, float scaleY= 1, float scaleZ= 1) const;
		void RenderXA(float x, float y, float z, float rotY = 0,float scaleX = 1, float scaleY= 1, float scaleZ= 1);
		void Cleanup(); // This is the destructor, but it doesn't get rid of it. It just unloads stuff, which we really need to do any time we change maps.
		int					meshIdNumber_;		// Number of the mesh id that XAnimator gives this. I need this, otherwise I can't reference shit.
		int					nextAnimSet;

	private:

		LPDIRECT3DDEVICE9	device_;			// Pointer to a rendering device
		LPD3DXMESH          mesh_;				// Pointer to a mesh object
		D3DMATERIAL9		*meshMaterials_;	// Array of materials for the mesh
		LPDIRECT3DTEXTURE9  *meshTextures_;		// Array of pointers to textures for the mesh
		DWORD               dwNumMaterials_;	// Number of materials (i.e. sub-meshes) in the mesh
		IXAnimator			*XAnimator_;		// Pointer to XAnim. This is important, otherwise I can't really access it.
		int					CurrentAnimSet_;	// Number of the current animation set of the model.
		int					TotalAnimSets_;		// Number of animation sets contained in the file.
};
#endif

